package com.yangsen.oss;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

public class filePath {
    private String folder;
    private String filePath;

    public filePath(String folder, String filePath) {
        this.folder = folder;
        this.filePath = filePath;
    }

    public static String filePathForBread(String key) {
        String[] paths = key.split("/");
        List<filePath> result = new ArrayList<filePath>();
        StringBuffer path = new StringBuffer();
        for (int i = 0; i < paths.length; i++) {
            path.append(paths[i]);
            path.append("/");
            result.add(new filePath(paths[i], path.toString()));
        }
//        System.out.println(JSON.toJSONString(result));
        return JSON.toJSONString(result);
    }

    public String getFilePath() {
        return filePath;
    }

    public String getFolder() {
        return folder;
    }
}
